package com.adams.sys.shortcut.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.adams.access.db.bean.Shortcut;
import com.adams.sys.shortcut.dao.ShortcutDao;
import com.adams.sys.shortcut.service.ShortcutService;

@Service("shortcutService")
@Transactional
public class ShortcutServiceImpl implements ShortcutService
{
	@Autowired
	private ShortcutDao shortcutDao;

	@Override
	public List<Shortcut> findByUserId(Long userId)
	{
		return shortcutDao.findByUserId(userId);
	}

	public void saveShortcut(List<Shortcut> shortcutList, Long userId)
	{
		shortcutDao.deleteByUserId(userId);
		if (shortcutList != null && !shortcutList.isEmpty())
		{
			for (Shortcut shortcut : shortcutList)
			{
				shortcutDao.save(shortcut);
			}
		}

	}

	public ShortcutDao getShortcutDao()
	{
		return shortcutDao;
	}

	public void setShortcutDao(ShortcutDao shortcutDao)
	{
		this.shortcutDao = shortcutDao;
	}

}
